﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tencent.OA.ACM.Service.Interface;
using Tencent.OA.ACM.Entity;
using System.Data;

namespace Tencent.OA.ACM.Proxy
{
    public class DatInfoProxy:ProxyBase<IDatInfoService>,IDatInfoService
    {
        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(Guid ID)
        {
            return pxy.Exists(ID);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(DatInfo model)
        {
            pxy.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DatInfo model)
        {
            return pxy.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(Guid ID)
        {

            return pxy.Delete(ID);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string IDlist)
        {
            return pxy.DeleteList(IDlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DatInfo GetModel(Guid ID)
        {

            return pxy.GetModel(ID);
        }


        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return pxy.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetListOrder(int Top, string strWhere, string filedOrder)
        {
            return pxy.GetListOrder(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<DatInfo> GetModelList(string strWhere)
        {
            DataSet ds = pxy.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<DatInfo> DataTableToList(DataTable dt)
        {
            List<DatInfo> modelList = new List<DatInfo>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                DatInfo model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new DatInfo();
                    if (dt.Rows[n]["ID"].ToString() != "")
                    {
                        model.ID = new Guid(dt.Rows[n]["ID"].ToString());
                    }
                    model.DBName = dt.Rows[n]["DBName"].ToString();
                    if (dt.Rows[n]["DataSize"].ToString() != "")
                    {
                        model.DataSize = decimal.Parse(dt.Rows[n]["DataSize"].ToString());
                    }
                    if (dt.Rows[n]["LogSize"].ToString() != "")
                    {
                        model.LogSize = decimal.Parse(dt.Rows[n]["LogSize"].ToString());
                    }
                    model.PhysicalDataPath = dt.Rows[n]["PhysicalDataPath"].ToString();
                    model.PhysicalLogPath = dt.Rows[n]["PhysicalLogPath"].ToString();
                    if (dt.Rows[n]["IsBackup"].ToString() != "")
                    {
                        model.IsBackup = int.Parse(dt.Rows[n]["IsBackup"].ToString());
                    }
                    if (dt.Rows[n]["BackupDate"].ToString() != "")
                    {
                        model.BackupDate = DateTime.Parse(dt.Rows[n]["BackupDate"].ToString());
                    }
                    model.BackupFilePath = dt.Rows[n]["BackupFilePath"].ToString();
                    if (dt.Rows[n]["DataIsPercentGrowth"].ToString() != "")
                    {
                        model.DataIsPercentGrowth = int.Parse(dt.Rows[n]["DataIsPercentGrowth"].ToString());
                    }
                    if (dt.Rows[n]["DataGrowthValue"].ToString() != "")
                    {
                        model.DataGrowthValue = int.Parse(dt.Rows[n]["DataGrowthValue"].ToString());
                    }
                    if (dt.Rows[n]["LogIsPercentGrowth"].ToString() != "")
                    {
                        model.LogIsPercentGrowth = int.Parse(dt.Rows[n]["LogIsPercentGrowth"].ToString());
                    }
                    if (dt.Rows[n]["LogGrowthValue"].ToString() != "")
                    {
                        model.LogGrowthValue = int.Parse(dt.Rows[n]["LogGrowthValue"].ToString());
                    }
                    model.Description = dt.Rows[n]["Description"].ToString();
                    model.Operator = dt.Rows[n]["Operator"].ToString();
                    if (dt.Rows[n]["LastUpdate"].ToString() != "")
                    {
                        model.LastUpdate = DateTime.Parse(dt.Rows[n]["LastUpdate"].ToString());
                    }
                    model.EditReason = dt.Rows[n]["EditReason"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return pxy.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  Method
    }
}
